package com.example.adminui.service.impl;

/**
 * 客户服务实现类
 * 提供客户相关的业务逻辑实现
 */

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.adminui.entity.Customer;
import com.example.adminui.entity.FollowRecord;
import com.example.adminui.mapper.CustomerMapper;
import com.example.adminui.mapper.FollowRecordMapper;
import com.example.adminui.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    /**
     * 客户数据访问接口
     */
    @Autowired
    private CustomerMapper customerMapper;

    @Autowired
    private FollowRecordMapper followRecordMapper;

    /**
     * 获取所有客户信息
     * @return 客户列表
     */

    @Override
    public List<Customer> getAllCustomers() {
        return customerMapper.selectList(new QueryWrapper<>());
    }

        /**
     * 根据ID获取客户信息
     * @param id 客户ID
     * @return 客户信息
     */
    @Override
    public Customer getCustomerById(Long id) {
        return customerMapper.selectById(id);
    }

        /**
     * 创建新客户
     * @param customer 客户信息
     */
    @Override
    public void createCustomer(Customer customer) {
        customerMapper.insert(customer);
    }

        /**
     * 更新客户信息
     * @param customer 客户信息
     */
    @Override
    public void updateCustomer(Customer customer) {
        customerMapper.updateById(customer);
    }

        /**
     * 删除客户
     * @param id 客户ID
     */
    @Override
    public void deleteCustomer(Long id) {
        customerMapper.deleteById(id);
    }

        /**
     * 获取客户的跟进记录
     * @param customerId 客户ID
     * @return 跟进记录列表
     */
    @Override
    public List<FollowRecord> getFollowRecordsByCustomerId(Long customerId) {
        QueryWrapper<FollowRecord> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_id", customerId);
        return followRecordMapper.selectList(queryWrapper);
    }

        /**
     * 根据ID获取跟进记录
     * @param id 跟进记录ID
     * @return 跟进记录信息
     */
    @Override
    public FollowRecord getFollowRecordById(Long id) {
        return followRecordMapper.selectById(id);
    }

        /**
     * 创建跟进记录
     * @param followRecord 跟进记录信息
     */
    @Override
    public void createFollowRecord(FollowRecord followRecord) {
        followRecordMapper.insert(followRecord);
    }

        /**
     * 更新跟进记录
     * @param followRecord 跟进记录信息
     */
    @Override
    public void updateFollowRecord(FollowRecord followRecord) {
        followRecordMapper.updateById(followRecord);
    }

        /**
     * 删除跟进记录
     * @param id 跟进记录ID
     */
    @Override
    public void deleteFollowRecord(Long id) {
        followRecordMapper.deleteById(id);
    }

    /**
     *
     * 根据条件进行模糊查询
     * */
    @Override
    public List<Customer> queryCustomer() {
        return customerMapper.queryCu

    }
}